//
//  MonitorSubmitController.m
//  village_ios
//
//  Created by mac on 2019/8/11.
//  Copyright © 2019 com.sw.village. All rights reserved.
//

#import "MonitorSubmitController.h"

@interface MonitorSubmitController ()
@property(weak) IBOutlet UITextField *titleTextField;
@property(weak) IBOutlet UITextField *userTextField;
@property(weak) IBOutlet UITextField *phoneTextField;
@property(weak) IBOutlet UITextField *addressTextField;
@property(weak) IBOutlet UITextView *descTextView;
@end

@implementation MonitorSubmitController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (IBAction)done {
    
    [SYProgressHUD show];
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    if (self.titleTextField.text) {
        [params addEntriesFromDictionary:@{@"title":self.titleTextField.text}];
    }
    if (self.userTextField.text) {
        [params addEntriesFromDictionary:@{@"username":self.userTextField.text}];
    }
    if (self.phoneTextField.text) {
        [params addEntriesFromDictionary:@{@"phone":self.titleTextField.text}];
    }
    if (self.addressTextField.text) {
        [params addEntriesFromDictionary:@{@"address":self.addressTextField.text}];
    }
    if (self.descTextView.text) {
        [params addEntriesFromDictionary:@{@"reason":self.descTextView.text}];
    }
    
    [APIManager requestWithUrlString:@"api/healthReport/addItem" params:params method:@"POST" success:^(id response) {
        
        [SYProgressHUD showInfoText:@"提交成功"];
        [self.navigationController popViewControllerAnimated:YES];
        
    } failure:^(NSError *error) {
        [SYProgressHUD showFailureText:@"提交失败"];
        
    }];
}

@end
